/**
 * This class holds all specifications for the panel for each system.
 * @author Araya Zaesim, Stanley Ayzenberg, Michelle Partogi, Adam Perez
 * @version 1.0
 */

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;


/**
 * @author Araya Zaesim, Stanley Ayzenberg, Michelle Partogi, Adam Perez
 * @version 1.0
 */
public class SystemPanel extends JPanel {

	/**
	 * Field lblDistance.
	 */
	private JLabel lblDistance;

	/**
	 * Field lblTechLevel.
	 */
	private JLabel lblTechLevel;

	/**
	 * Field lblPirates.
	 */
	private JLabel lblPirates;

	/**
	 * Field lblPolice.
	 */
	private JLabel lblPolice;

	/**
	 * Field lblGovernment.
	 */
	private JLabel lblGovernment;

	/**
	 * Field lblResource.
	 */
	private JLabel lblResource;

	/**
	 * Field lblCurrentSolarSystem.
	 */
	private JLabel lblCurrentSolarSystem;

	/**
	 * Field lblSize.
	 */
	private JLabel lblSize;

	/**
	 * Field lblEvent.
	 */
	private JLabel lblEvent;

	/**
	 * Field type.
	 */
	protected String type = null;

	/*
	 * This can only be a constructor for the Target System Info.
	 */
	/**
	 * Constructor for SystemPanel.
	 * @param type String
	 */
	public SystemPanel(String type) {
		// setLayout(new GridLayout(8,1));
		this.type = type;
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

		lblCurrentSolarSystem = new JLabel(type + " Solar System:");
		add(lblCurrentSolarSystem);

		lblResource = new JLabel("Resource: ");
		add(lblResource);

		lblGovernment = new JLabel("Government: ");
		add(lblGovernment);

		lblPolice = new JLabel("Police: ");
		add(lblPolice);

		lblPirates = new JLabel("Pirates: ");
		add(lblPirates);

		lblTechLevel = new JLabel("Tech Level: ");
		add(lblTechLevel);

		lblSize = new JLabel("Size:");
		add(lblSize);

		if (type.equals("Target")) {
			lblDistance = new JLabel("Distance: ");
			add(lblDistance);
		} else {
			lblEvent = new JLabel("Event: ");
			add(lblEvent);
		}
		// need fuel level elsewhere
	}

	/*
	 * This can only be a constructor for the Current System Info.
	 */
	/**
	 * Constructor for SystemPanel.
	 * @param type String
	 * @param system SolarSystem
	 */
	public SystemPanel(String type, SolarSystem system) {
		this(type);
		updatePanel(system);

	}

	/*
	 * Call whenever systems info needs to be changed
	 * 
	 * @param currentSystem a SolarSystem
	 * 
	 * @param marketplace a Marketplace to get events
	 */
	/**
	 * Method update.
	 * @param system SolarSystem
	 */
	public final void updatePanel(SolarSystem system) {
		lblCurrentSolarSystem.setText(type + " Solar System: "
				+ system.getName());
		lblResource.setText("Resource: " + system.getResource());
		lblGovernment.setText("Government: " + system.getGovernment());
		lblTechLevel.setText("Tech Level: " + system.getTechLevelName());
		lblSize.setText("Size: " + system.getSize());
		lblPolice.setText("Police: " + system.getPoliceChance());
		lblPirates.setText("Pirates: " + system.getPirateChance());
		// lblEvent.setText("Event: " + system.getEvent());
		if (type.equals("Target")) {
			lblDistance.setText("Distance: " + system.getDistance(system));
		}
	}

	/*
	 * Overloading. Will only be called by tarSystem
	 * 
	 * @param currentSystem a SolarSystem
	 * 
	 * @param targetSystem a SolarSystem
	 */
	/**
	 * Method update.
	 * @param currSystem SolarSystem
	 * @param tarSystem SolarSystem
	 */
	public void update(SolarSystem currSystem, SolarSystem tarSystem) {
		updatePanel(tarSystem);
		lblDistance.setText("Distance: " + currSystem.getDistance(tarSystem));
	}

	/*
	 * Clears system panel. Will only be called by target system.
	 */
	/**
	 * Method clear.
	 */
	public void clear() {
		lblCurrentSolarSystem.setText(type + " Solar System: ");
		lblResource.setText("Resource: ");
		lblGovernment.setText("Government: ");
		lblTechLevel.setText("Tech Level: ");
		lblSize.setText("Size: ");
		lblPolice.setText("Police: ");
		lblPirates.setText("Pirates: ");
		if (type.equals("Target")) {
			lblDistance.setText("Distance: ");
		}
	}

	/**
	 * Method setEvent.
	 * @param event String
	 */
	public void setEvent(String event) {
		lblEvent.setText("Event: " + event);
	}
}
